package today.rocky.memory.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import today.rocky.memory.common.CommonResult;
import today.rocky.memory.util.FastDFSClient;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

/**
 * @author Rocky
 * @version 1.0
 * @date 2020/5/22 19:36
 * @description
 */
@Slf4j
@CrossOrigin
@RestController
@RequestMapping("/tool")
public class ToolController {

	@Autowired
	private FastDFSClient fastDFSClient;

	@PostMapping("/uploadImage")
	public CommonResult uploadImage(@RequestParam("imgFile") MultipartFile  imgFile) throws IOException {
		String url = fastDFSClient.uploadBase64(imgFile);
		log.info(url);
		Map<String,Object> map = new HashMap<>(8);
		map.put("flag",0);
		map.put("url",url);
		map.put("msg","上传成功");
		return CommonResult.success(map);
	}


}
